package com.jml.zookeeper.一期.zookeeper分布式锁;

//使用多线程模拟生成订单号,有多个订单重复
public class OrderServiceNoLock implements Runnable {
	private OrderNumGenerator orderNumGenerator = new OrderNumGenerator();

	@Override
	public void run() {
		getNumber();
	}

	public void getNumber() {
		String number = orderNumGenerator.getNumber();
		System.out.println(Thread.currentThread().getName() + ",生成订单ID:" + number);
	}

	public static void main(String[] args) {
		System.out.println("####生成唯一订单号###");
		for (int i = 0; i < 100; i++) {
			new Thread(new OrderServiceNoLock()).start();
		}

	}
}

